package com.launch.wlfw.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.launch.wlfw.common.Result;
import com.launch.wlfw.dao.BookInfoMapper;
import com.launch.wlfw.pojo.BookInfo;
import com.launch.wlfw.pojo.TypeInfo;
import com.launch.wlfw.service.BookInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("bookInfoService")
public class BookInfoServiceImpl implements BookInfoService {

    @Resource
    BookInfoMapper bookInfoMapper;

    @Override
    public PageInfo<BookInfo> getListBook(BookInfo bookInfo, Integer page, Integer limit) {
        PageHelper.startPage(page , limit);
        return PageInfo.of(bookInfoMapper.getListBook(bookInfo));
    }

    @Override
    public int addBook(BookInfo book) {
        return bookInfoMapper.addBook(book);
    }

    @Override
    public int updateBook(BookInfo book) {
        return bookInfoMapper.updateBook(book);
    }

    @Override
    public int deleteBook(int bookId) {
        return bookInfoMapper.deleteBookById(bookId);
    }

    @Override
    public List<TypeInfo> findAllList() {
        return bookInfoMapper.findAllList();
    }

    @Override
    public BookInfo getBookById(int id) {
        return bookInfoMapper.getBookById(id);
    }

}
